{% extends "groups/base.html" %}

{% comment %}
<!--
  Copyright (C) 2010 ZHENG Zhong <http://www.zhengzhong.net/>
  Created on 2010-02-08.
  $Id$
-->
{% endcomment %}

{% load friday_extra %}

{#________________________________________________________________________________________________#}

{% block html_title %} {{ activity.title|escape }} {% endblock %}

{#________________________________________________________________________________________________#}

{% block sidebar %}

  <!-- information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <div class="section">

    <h2>Information:</h2>

    {% if activity.geo_pt %}
      <div id="map-canvas" class="s-map"></div>
      <p><a href="#TODO">&raquo; View larger map</a></p>
      <script type="text/javascript">//<![CDATA[
        $(function() {
          friday.showMap({{ activity.geo_pt.lat }}, {{ activity.geo_pt.lon }}, "#map-canvas");
        });
      //]]></script>
    {% endif %}

    <dl>
      <dt>
        <img class="icon" src="{{ static_ }}/images/address.png" alt="Address"/>
        Location:
      </dt>
      <dd>
        {{ activity.address|default:"Address not specified"|escape }}<br/>
        {{ activity.city|escape }}
      </dd>
    </dl>

    <dl>
      <dt>
        <img class="icon" src="{{ static_ }}/images/date.png" alt="Date"/>
        Date:
      </dt>
      <dd>{{ activity.date|date:"l, d N Y" }}</dd>
    </dl>

    <dl>
      <dt>
        <img class="icon" src="{{ static_ }}/images/group.png" alt="Headcount"/>
        Headcount:
      </dt>
      <dd>
        {{ activity.headcount }} heads /
        {% if activity.places %}
          {{ activity.places }} places
        {% else %}
          Unlimited places
        {% endif %}
      </dd>
    </dl>

    <dl>
      <dt>
        <img class="icon" src="{{ static_ }}/images/status.png" alt="Status"/>
        Status:
      </dt>
      <dd>
        {% if activity.is_past %}
          <img class="icon" src="{{ static_ }}/images/lock.png" alt="Past"/>
          This activity is past
        {% else %}
          {% if activity.is_closed %}
            <img class="icon" src="{{ static_ }}/images/lock.png" alt="Closed"/>
            This activity is closed
          {% else %}
            <img class="icon" src="{{ static_ }}/images/ok.png" alt="Open"/>
            This activity is open
          {% endif %}
        {% endif %}
      </dd>
    </dl>

    {% if activity.related_link %}
      <dl>
        <dt>
          <img class="icon" src="{{ static_ }}/images/website.png" alt="Website"/>
          Related link:
        </dt>
        <dd>
          <a href="{{ activity.related_link }}">{{ activity.related_link|summary:32 }}</a>
        </dd>
      </dl>
    {% endif %}

  </div>

  <!-- submitter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <div class="section">

    <div class="user-box">
      <div class="user-avatar">
        <a href="{% url friday.view_profile username=activity.submitter.username %}">
          <img src="{% url friday.view_avatar username=activity.submitter.username %}" alt="{{ activity.submitter|escape }}"/>
        </a>
      </div>
      <div class="user-info">
        Added by 
        <a href="{% url friday.view_profile username=activity.submitter.username %}">{{ activity.submitter|escape }}</a>
        <br/>
        on {{ activity.submit_date|date:"d N Y" }}
      </div>
      <div class="clear"></div>
    </div>

  </div>

  <!-- administration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  {% if activity_access.can_edit or activity_access.can_delete %}
    <div class="section">
      <h2>Administrate:</h2>
      <ul>
        {% if activity_access.can_edit %}
          <li>
            <a href="{% url friday.edit_activity group_uid=activity.group.uid activity_id=activity.id %}">
              Edit this activity
            </a>
          </li>
        {% endif %}
        {% if activity_access.can_delete %}
          <li>
            <a href="{% url friday.delete_activity group_uid=activity.group.uid activity_id=activity.id %}">
              Delete this activity
            </a>
          </li>
        {% endif %}
      </ul>
    </div>
  {% endif %}

{% endblock %}

{#________________________________________________________________________________________________#}

{% block content %}

  <div class="section">
    <h1>{{ activity.title|escape }}</h1>
    <h5>
      {{ activity.date|date:"l, d N Y" }}
      ( {{ activity.date|prettify_datetime }} )
      {% if activity.is_past or activity.is_closed %}
        <img class="icon" src="{{ static_ }}/images/lock.png" alt="Past or Closed"/>
      {% endif %}
    </h5>
  </div>

  <div class="section">
    <h2>Description:</h2>
    {{ activity.content|escape|linebreaks }}
  </div>

  <!-- attenders ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <div id="load-attenders"></div>
  <script type="text/javascript">//<![CDATA[
    $(function() {
      $("#load-attenders").load("{% url friday.view_attenders group_uid=group.uid activity_id=activity.id %}");
    });
  //]]></script>

  <!-- activity tabs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <div class="section">
    <div id="activity-tabs">
      <ul>
        <li><a href="{% url friday.view_comments ref_type=activity.model_name ref_pk=activity.id %}">Comments</a></li>
      </ul>
    </div>
    <script type="text/javascript">//<![CDATA[
      $(function() {
        $("#activity-tabs").tabs({
          ajaxOptions: {
            error: function(xhr, status, index, anchor) {
              if (index == 0) {
                target = "comments";
              } else {
                target = "unknown objects";
              }
              $(anchor.hash).html("Failed to load " + target + " via AJAX: server error.");
            }
          }
        });
      });
    //]]></script>
  </div>

{% endblock %}{# content #}



